<% if current_user && current_user.newbie? %>
<div class="mb-4 card">
  <div class="card-header"><%= t("topics.newbie_tip") %></div>
  <div class="card-body">
    <%= raw Setting.newbie_notices %>
  </div>
</div>
<% else %>

<div class="mb-4 card">
  <div class="card-body">
    <%= link_to t('topics.new_topic'), main_app.new_topic_path(node: @node&.id), class: 'btn btn-primary btn-block' %>
  </div>
</div>
<% end %>

<%= render "topics/sidebar_box_tips" %>

<%= raw Setting.topic_index_sidebar_html %>

<% cache(["sidebar_active_users",Time.now.strftime("%Y-%m-%d %H")]) do %>
<div class="mb-4 card">
  <div class="flex items-baseline justify-between card-header">
    <%= t('common.active_users') %>
    <a href="<%= main_app.users_path %>" class="text-sm text-gray-400"><%= t("common.more") %></a>
  </div>
  <div class="grid grid-cols-4 gap-2 p-3">
    <% Counter.active_users(limit: 20).each do |user| %>
      <div class="flex flex-col gap-1 text-center">
        <%= user_avatar_tag(user, :md) %>
        <%= user_name_tag(user, class: "text-sm text-gray-600 truncate") %>
      </div> 
    <% end %>
  </div>
</div>
<% end %>

<% cache(["sidebar_statistics",Time.now.strftime("%Y-%m-%d %H")]) do %>
<div class="mb-4 card">
  <div class="card-header"><%= t("common.statics")%></div>
  <ul class="list-group list-group-flush">
    <li class="list-group-item"><%= t("common.statics_users_count", count: User.unscoped.count) %></li>
    <li class="list-group-item"><%= t("common.statics_topics_count", count: Topic.unscoped.count) %></li>
    <li class="list-group-item"><%= t("common.statics_replies_count", count: Reply.unscoped.count) %></li>
  </ul>
</div>
<% end %>
